# -*- coding: utf-8 -*-
# @Time : 2019/1/11 9:27
# @Author : Administrator
# @File : employment.py
# @Project : python
# @title : 接口测试 -- 培训资源
import unittest,ddt
from woniuboss_interface.util.read_data import Read_Excel
from woniuboss_interface.common.login_decode import Login

excel=Read_Excel()
session,host,excel_path = Login()
@ddt.ddt
class Resource(unittest.TestCase):
    info = excel.excel(excel_path,9)
    modify = excel.excel(excel_path,10)
    @classmethod #装饰器
    def setUpClass(cls): #登录
        print("培训资源")

    @ddt.data(*info)
    def test_001_add(self,value):    #新增资源
        session.post(url=host+"/cons/showCusInfo",
                        data={"tel":value["tel"]})   #此处有一个post请求，电话请求
        res = session.post(url=host+"/cons/addCus",
                                data = {"cus.tel":value["tel"],"cus.name":value["name"],"cus.sex":"男",
                                        "cus.last_status":"新入库","cus.email":0,"cus.qq":value["QQ"],
                                        "cus.school":value["school"],"cus.education":"本科","cus.major":value["major"],
                                        "cus.intent":value["job"],"cus.workage":"应届毕业生","cus.salary":"",
                                        "cus.source":"双选会","cus.applposition":"","cus.age":value["age"],"cus.eduexp":"",
                                        "cus.experience":value["exp"],"cus.last_tracking_remark":value["fav"]})
        self.assertIn(value["expect"],res.text)   #断言


    @ddt.data(*modify)
    def test_002_modify(self,value):    #修改资源
        res = session.post(url=host+"/resource/modifyCusInfo",
                                data = {"cus.tel":value["tel"],"cus.name":value["name"],"cus.sex":"男",
                                        "cus.last_status":"新入库","cus.email":0,"cus.qq":value["QQ"],
                                        "cus.school":value["school"],"cus.education":"本科","cus.major":value["major"],
                                        "cus.intent":value["job"],"cus.workage":"应届毕业生","cus.salary":"",
                                        "cus.source":"双选会","cus.applposition":"","cus.age":value["age"],"cus.eduexp":"",
                                        "cus.experience":value["exp"],"cus.last_tracking_remark":value["fav"]})
        self.assertIn(value["expect"],res.text)   #断言

    def test_004_fellow(self):   #跟踪资源
        res = session.post(url=host+"/resource/saveTrackingRecord",
                      data={"fee":"18800元","id":"592832","nextTime":"2019-01-24","priority":"低","remark":"哈哈哈哈",
                            "status":"已上门"})
        # print(res.text)
        self.assertEqual("success",res.text)  #断言

    def test_005_transmit(self):  #转交责任人
        res = session.post(url=host+"/transmit/updateTransmit",
                      data={"arr[]":"592831","workId":"WNCD023"})
        # print(res.text)
        self.assertEqual("success",res.text)  #断言

    def test_abandon005(self):      #废弃资源
        r = session.post(url=host+"/resource/abandonResource",
                        data={"arr[]":"592794,WNCD000"})
        # print(r.text)
        self.assertEqual(r.text,"废弃资源完成.")

    def test_own007(self):        #认领资源，相应为空
        r=session.post(url=host+"/public/ownResource",
                      data={"arr[]":"592791"})
        print(r.text)


if __name__ == '__main__':
    unittest.main()

